<?php namespace Home\Controller; 

use Hdphp\Controller\Controller;

//测试控制器
class LoginController extends Controller{
    //动作
    public function index(){
    	if(IS_POST){
			//接收用户名和密码
			$username=Q('post.username');
			$password = Q('post.password');
			$model=new \Common\Model\Homeuser;
			if ($model->vLogin($username,$password)) {
				//跳转到首页
				go(U('Index/index'));
			}
			$this->error($model->getError());
		}
       View::make();
    }
    //退出
	public function out(){
		session_unset();
		session_destroy();
		go(U('Index/index'));
	}
	public function add()
	{
		if (IS_POST) {
			$username=Q('post.username');
			$password = Q('post.password');
			$password1 = Q('post.password1');
			$model=new \Common\Model\Homeuser;
			if ($model->store($username,$password,$password1)) {
				//跳转到首页
				View::success('注册成功',U('index'));
			}
			$this->error($model->getError());
		}
		View::make();
	}
}
